<?php
 require_once("../include/httpclient.php");
 require_once("../include/db_mysql.php");
/*serviceurl:30
根据landmarkid获取facilityid数组
$arg是landmarkid
返回值：一个数组key为facilityId，value为行政区名(district_county表的district_county_name字段)+street_doorNumber 
*/
function GetFacilityArrayByLandmark($arg)
{			
	$landMarkBuildingId = $arg['landMarklBuildingId'];
	$facilityIdArray = array();
	$link = new SqlClass();
	//连接数据库
	$link->connect();
	//执行sql语句
	
	$sqlCommand = "select facilityId,district_county_Id,street_doorNumber from facility where cityId =
	(select cityId from district_county where district_county_Id =
	(select district_county_Id from landmarklbuilding where landMarklBuildingId = $landMarkBuildingId))";
	$result = $link->exec_sql($sqlCommand);	
	while($row=mysql_fetch_array($result))
	{	 	
		$district_county_Id = $row['district_county_Id'];
		$sqlCommand = "select district_county_Name from district_county where district_county_Id = $district_county_Id ";
		$res = $link->exec_sql($sqlCommand);
		while($eachrow = mysql_fetch_array($res))
		{
			$location = $eachrow['district_county_Name'].$row['street_doorNumber'];
			break;
		}
		$facilityIdArray[$row['facilityId']] = $location ;					
		//根据facilityId取得所有party信息以及facility信息，facility由行政区+street_doorNumber组成
	}		
	$link->close();
	return json_encode($facilityIdArray);  
}
?>